import React from 'react';
import {
    Table
} from 'antd';
import axios from 'axios';
import intercept from '../../../utils/intercept';
import {config} from 'utils';

//订单详情组件
export default class OrderList extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: true,
            data: []
        };
    }

    componentDidMount() {
        this.getOrderdetail();
    };
    getOrderdetail() {
        const token = sessionStorage.getItem("token");
        // this.setState({loading: true});
        const url = `${config.api}Rental/GetDriverStaticsDetail?day=${this.props.day}&driverName=${this.props.driverName}`;
        axios
            .get(url,{headers:{Authorization:'Bearer ' + token}})
            .then((data) => {
                // console.log(data);
                this.setState({loading: false, data: data.data.driverStatics});
            })
            .catch(err => {
                intercept;
            })
    };
    render() {
        const column = [
            {
                title: '派车单号',
                dataIndex: 'sendOrderID',
                width: 150
            }, {
                title: '线路',
                dataIndex: 'lineName',
                width: 150
            }, {
                title: '人数',
                dataIndex: 'tel',
                width: 150
            }
            , {
                title: '总金额',
                dataIndex: 'totalMoney',
                width: 150,
            }
            , {
                title: '线上收款',
                dataIndex: 'onlinePay',
                width: 150
            }
            , {
                title: '线下收款',
                width: 150,
                render:(record) => {
                    return(
                      <span>{record.totalMoney - record.onlinePay}</span>
                    )
                }
            }
        ];
        return (<Table
            columns={column}
            // rowClassName={() => {return 'childtable'}}
            dataSource={this.state.data}
            bordered={true}
            pagination={false}
            rowkey={record => record.driverStatics}
            size="small"/>);
    }
}
